/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lifecraft;


public class World {
    public Chunk First,a,b,c;
    public int x=0;
    public int y=0;
    
    World(){
        First = new Chunk();
        a = new Chunk();
        b= new Chunk();
        c=new Chunk();
        First.left=a;
        First.right=b;
        b.left = First;
        First.down=c;
        a.right=First;
        c.up = First;
        First.create();
        a.create();
        b.create();
        c.create();
    }
    void insertAt(int x, int y, SurfC ID){
        if(y+this.y>0){
            if((x+this.x>0)&&(x+this.x<=(32*35)))
                First.insertAt(x+this.x, y+this.y, ID);
            else if((x + this.x >(32*35))&&(x + this.x <= 2*(32*35)))
                b.insertAt(x+this.x-(32*35), y+this.y, ID);
            
            else if((x + this.x <0)&&(x + this.x >= -(32*35)))
                a.insertAt(x+this.x+(32*35), y+this.y, ID);
        }
        else 
        if((x+this.x>0)&&(x+this.x<=(32*35)))
           c.insertAt(x+this.x, y+this.y + (32*25), ID);
    }
    void destroyAt(int x, int y){
        if(x+this.x>0)
            First.destroyAt(x+this.x, y+this.y);
        else{
            a.destroyAt(x+this.x+(32*35), y+this.y);
        }
        
    }
    void reset(){
        First.reset();
        a.reset();
        b.reset();
        c.reset();
    }
    void Draw(boolean pause)
    {
        First.Draw(0, 0, pause);
        a.Draw(-(32*35), 0, pause);
        
        b.Draw((32*35), 0, pause);
        c.Draw(0, -(32*25), pause);
        
    }
    
}
